home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / OpenTptLinks.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  6KB  |  240 lines

  1. /*
  2.     File:        OpenTptLinks.h
  3.  
  4.     Contains:    Definitions for link modules
  5.  
  6.     Copyright:    © 1994-1996 by Apple Computer, Inc., all rights reserved.
  7.  
  8.  
  9. */
  10.  
  11.  
  12.  
  13. #ifndef __OPENTPTLINKS__
  14. #define __OPENTPTLINKS__
  15.  
  16. #ifndef __OPENTRANSPORT__
  17. #include <OpenTransport.h>
  18. #endif
  19.  
  20. /*******************************************************************************
  21. ** Device Types for OTPortRefs
  22. ********************************************************************************/
  23.  
  24. #define kPortBaseResID    1000
  25.  
  26. enum
  27. {
  28.     kOTADEVDevice            = 1,        /* An Atalk ADEV        */
  29.     kOTMDEVDevice            = 2,        /* A TCP/IP MDEV        */
  30.     kOTLocalTalkDevice        = 3,        /* LocalTalk            */
  31.     kOTIRTalkDevice            = 4,        /* IRTalk                */
  32.     kOTTokenRingDevice        = 5,        /* Token Ring            */
  33.     kOTISDNDevice            = 6,        /* ISDN                    */
  34.     kOTATMDevice            = 7,        /* ATM                    */
  35.     kOTSMDSDevice            = 8,        /* SMDS                    */
  36.     kOTSerialDevice            = 9,        /* Serial                 */
  37.     kOTEthernetDevice        = 10,        /* Ethernet                */
  38.     kOTSLIPDevice            = 11,        /* SLIP Pseudo-device    */
  39.     kOTPPPDevice            = 12,        /* PPP Pseudo-device    */
  40.     kOTModemDevice            = 13,        /* Modem Pseudo-Device    */
  41.     kOTFastEthernetDevice    = 14,        /* 100 MB Ethernet        */
  42.     kOTFDDIDevice            = 15,        /* FDDI                    */
  43.     kOTATMLANEDevice        = 16,        /* ATM LAN emulation    */
  44.     kOTATMSNAPDevice        = 17        /* ATM SNAP emulation    */
  45. };
  46.  
  47. /*******************************************************************************
  48. ** Interface option flags
  49. ********************************************************************************/
  50.  
  51. enum
  52. {
  53.     //
  54.     // Ethernet framing options
  55.     //
  56.     kOTFramingEthernet        = 0x01,
  57.     kOTFramingEthernetIPX    = 0x02,
  58.     kOTFraming8023            = 0x04,
  59.     kOTFraming8022            = 0x08
  60. };
  61.  
  62. enum
  63. {
  64.     //
  65.     // RawMode options
  66.     //
  67.     kOTRawRcvOn                    = 0,
  68.     kOTRawRcvOff                = 1,
  69.     kOTRawRcvOnWithTimeStamp    = 2
  70. };
  71.  
  72. enum
  73. {
  74.     //
  75.     // OPT_SETPROMISCUOUS value
  76.     //
  77.     DL_PROMISC_OFF            = 0
  78. };
  79.  
  80. /*******************************************************************************
  81. ** Module definitions
  82. ********************************************************************************/
  83. //
  84. // XTI Levels
  85. //
  86. enum
  87. {
  88.     LNK_ENET    = 'ENET',
  89.     LNK_TOKN    = 'TOKN',
  90.     LNK_FDDI    = 'FDDI',
  91.     LNK_TPI        = 'LTPI'
  92. };
  93. //
  94. // Module IDs
  95. //
  96. enum
  97. {
  98.     kT8022ModuleID        = 7100,
  99.     kEnetModuleID        = 7101,
  100.     kTokenRingModuleID    = 7102,
  101.     kFDDIModuleID        = 7103
  102. };
  103. //
  104. // Module Names
  105. //
  106. #define kEnet8022Name    "enet8022x"
  107. #define kEnetName        "enet"
  108. #define kFastEnetName    "fenet"
  109. #define kTokenRingName    "tokn"
  110. #define kFDDIName        "fddi"
  111. #define kIRTalkName        "irtlk"
  112. #define kSMDSName        "smds"
  113. #define kATMName        "atm"
  114. #define kT8022Name        "tpi8022x"
  115. #define kATMLANEName    "atmlane"
  116. #define kATMSNAPName    "atmsnap"
  117. //
  118. // Address Family
  119. //
  120. enum
  121. {
  122.     AF_8022        = 8200    // Our 802.2 generic address family
  123. };
  124.  
  125. /*******************************************************************************
  126. ** Options
  127. ********************************************************************************/
  128.  
  129. enum
  130. {
  131.     OPT_ADDMCAST         = 0x1000,
  132.     OPT_DELMCAST         = 0x1001,
  133.     OPT_RCVPACKETTYPE    = 0x1002,
  134.     OPT_RCVDESTADDR        = 0x1003,
  135.     OPT_SETRAWMODE        = 0x1004,
  136.     OPT_SETPROMISCUOUS    = 0x1005
  137. };
  138.  
  139. enum OTPacketType
  140. {
  141.     kETypeStandard=0,
  142.     kETypeMulticast,
  143.     kETypeBroadcast,
  144.     kETRawPacketBit = 0x80000000,
  145.     kETTimeStampBit = 0x40000000
  146. };
  147.  
  148. /*******************************************************************************
  149. ** Link related constants
  150. ********************************************************************************/
  151.  
  152. enum
  153. {
  154.     //
  155.     // length of an ENET hardware addressaddress
  156.     //
  157.     kMulticastLength            = 6,
  158.     k48BitAddrLength            = 6,
  159.     //
  160.     // The protocol type is our DLSAP
  161.     //
  162.     k8022DLSAPLength            = 2,
  163.     //
  164.     k8022SNAPLength             = 5,
  165.     //
  166.     // length of an address field used by the ENET enpoint
  167.     //    = k48BitAddrLength + sizeof(protocol type)
  168.     //
  169.     kEnetAddressLength            = k48BitAddrLength + k8022DLSAPLength,
  170.     //
  171.     // Special DLSAPS for ENET
  172.     //
  173.     kSNAPSAP                    = 0x00AA,
  174.     kIPXSAP                        = 0x00FF,
  175.     kMax8022SAP                    = 0x00FE,
  176.     k8022GlobalSAP                = 0x00FF,
  177.     kMinDIXSAP                    = 1501,
  178.     kMaxDIXSAP                    = 0xFFFFU
  179. };
  180.  
  181.  
  182.  
  183. /*******************************************************************************
  184. ** Generic Address Structure
  185. ********************************************************************************/
  186.  
  187. struct T8022Address
  188. {
  189.         OTAddressType    fAddrFamily;
  190.         UInt8            fHWAddr[k48BitAddrLength];
  191.         UInt16            fSAP;
  192.         UInt8            fSNAP[k8022SNAPLength];
  193. };
  194.  
  195. enum
  196. {
  197.         k8022BasicAddressLength = sizeof(OTAddressType) + k48BitAddrLength +
  198.                                                 sizeof(UInt16),
  199.         k8022SNAPAddressLength = sizeof(OTAddressType) + k48BitAddrLength +
  200.                                     sizeof(UInt16) + k8022SNAPLength
  201. };
  202.  
  203. /*******************************************************************************
  204. ** Some helpful stuff for dealing with 48 bit addresses
  205. ********************************************************************************/
  206.  
  207. #define OTCompare48BitAddresses(p1, p2)                                                        \
  208.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&        \
  209.      *(const UInt16*)(((const UInt8*)(p1))+4) == *(const UInt16*)(((const UInt8*)(p2))+4) )
  210.  
  211. #define OTCopy48BitAddress(p1, p2)                                                \
  212.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),            \
  213.      *(UInt16*)(((UInt8*)(p2))+4) = *(const UInt16*)(((const UInt8*)(p1))+4) )
  214.  
  215. #define OTClear48BitAddress(p1)                                                    \
  216.     (*(UInt32*)((UInt8*)(p1)) = 0,                                                \
  217.      *(UInt16*)(((UInt8*)(p1))+4) = 0 )
  218.  
  219. #define OTCompare8022SNAP(p1, p2)                                                        \
  220.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&    \
  221.      *(((const UInt8*)(p1))+4) == *(((const UInt8*)(p2))+4) )
  222.  
  223. #define OTCopy8022SNAP(p1, p2)                                                \
  224.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),        \
  225.      *(((UInt8*)(p2))+4) = *(((const UInt8*)(p1))+4) )
  226.  
  227. #define OTIs48BitBroadcastAddress(p1)                    \
  228.     (*(UInt32*)((UInt8*)(p1)) == 0xffffffff &&            \
  229.      *(UInt16*)(((UInt8*)(p1))+4) == 0xffff )
  230.  
  231. #define OTSet48BitBroadcastAddress(p1)                    \
  232.     (*(UInt32*)((UInt8*)(p1)) = 0xffffffff,                \
  233.      *(UInt16*)(((UInt8*)(p1))+4) = 0xffff )
  234.  
  235. #define OTIs48BitZeroAddress(p1)                \
  236.     (*(UInt32*)((UInt8*)(p1)) == 0 &&             \
  237.      *(UInt16*)(((UInt8*)(p1))+4) == 0 )
  238.  
  239. #endif
  240.